//C7:ep7_8.c: Enter one line text,count the total of words.
// like : "was me". count is two. Splite them with space.
#include <stdio.h>
int main(void)
{
    char string[81];
    int i, cnt = 0, word = 0;
    char c;
    printf("Enter one line text:\n");
    gets(string);
    //fgets(string,sizeof(string),stdin);
    for(i = 0; (c = string[i])!= '\0'; i++)
    {
        if(c == ' ')
        {
            word = 0;
        }
        else if(word == 0)
        {
            word = 1;
            cnt++;
        }
    }
    printf("There ar %d words in the line.\n", cnt);
}